﻿// -------------------------------------------------------------------------
//    @FileName         :    NFCityNpcLevelExt.h
//    @Author           :    Gao.Yi
//    @Date             :    2025-09-29
//    @Email			:    445267987@qq.com
//    @Module           :    NFCityNpcLevelExt
//    @Desc             :
//
// -------------------------------------------------------------------------

#pragma once

#include "NFComm/NFObjCommon/NFObject.h"
#include "NFComm/NFShmStl/NFShmVector.h"

class NFCityNpc;

class NFCityWorldObject;
class NFCityPlayer;

const int MAX_NPC_FUNCTION_NUM = 5;

struct NFCityNpcLevelInfo
{
    NFCityNpcLevelInfo()
    {
        if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode())
        {
            CreateInit();
        }
        else
        {
            ResumeInit();
        }
    }

    int CreateInit()
    {
        m_iTriggerNpcId = 0;
        m_iTriggerCnt = 0;
        m_bInTrigger = false;
        m_iTriggerTime = 0;
        return 0;
    }

    int ResumeInit()
    {
        return 0;
    }

    int m_iTriggerNpcId;
    int m_iTriggerCnt;
    bool m_bInTrigger;
    int m_iTriggerTime;
};


class NFCityNpcLevelExt
{
public:
    NFCityNpcLevelExt();
    ~NFCityNpcLevelExt();
    int CreateInit();
    int ResumeInit();

public:
    int Init(NFCityNpc* pNpc);
    bool IsVisibleByQuest(int iQuestId);
    bool IsHideVisible(NFCityWorldObject* pAcceptWo);
    int CheckTriggerLevel(NFCityPlayer* pPlayer, int iLevelId);
    int OnTriggerLevel(NFCityNpc* pNpc, int iLevelId);
    int OnBattleEnd(NFCityNpc* pNpc, int iLevelId, bool bIsWin);

    void SetTransNpcObjId(int32_t iNpcObjId) { m_iTransNpcObjId = iNpcObjId; }
    int32_t GetTransNpcObjId() { return m_iTransNpcObjId; }

private:
    bool IsLevelFull() { return m_astLevelInfo.full(); }
    NFCityNpcLevelInfo* FindLevelInfo(int iLevelId);

private:
    NFShmVector<NFCityNpcLevelInfo, MAX_NPC_FUNCTION_NUM> m_astLevelInfo;

    int m_iTransNpcObjId; //battle npc entrance
};
